<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>
    <script>
        // 声明一个最大值max 最小值min
        let arr = [2, 6, 1, 77, 54, 34, 7]
        let max = arr[0]
        let min = arr[0]
        // 遍历数组，如果数组的数大于max，则把这数给max
        for (i = 1; i < arr.length; i++) {
            if (max < arr[i]) {
                max = arr[i]
            }
            if (min > arr[i]) {
                min = arr[i]
            }
        }
        //输出max
        console.log(max);
        //输出min
        console.log(min);


    </script>
</body>

</html>